#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7;
int dp[1005][1005][2],cnt[1005][1005][2];
int pw[1005],pww[1005];
int ksm(int x,int y){
	int ret=1;while(y){
		if(y%2==1) ret=(ret*x)%mod;
		x=(x*x)%mod,y/=2;
	}return ret;
}
string s,x,y;
int k,n,ans;
void xiao(int i,int sum,int pd,int num){
//	cout<<pd<<i<<" "<<sum<<'\n';
	for(;i<=n;i++){
		int xb;
		if(pd==0) xb=s[i-1];
		else xb=1-s[i-1];
		sum=(sum+pw[n-i]*xb%mod)%mod;
		if(xb!=x[i]-'0'){
			if(xb>x[i]-'0'){
				sum=(sum-pw[n-i]*xb%mod+mod)%mod;
				sum=(sum+pw[n-1]*(1-xb)%mod)%mod;
				num++;pd=1-pd;
			}
			else{
				sum=(sum-pw[n-i]*xb%mod+mod)%mod;
				sum=(sum+pw[n-1]*(1-xb)%mod)%mod;
				num++;pd=1-pd;
			}
		}
		if(abs(num-k)<=1&&num<=k) ans=(ans+sum)%mod;
	}
}
signed main(){
//	freopen("lost.in","r",stdin);
//	freopen("lost.out","w",stdout);
//	ios::sync_with_stdio(0);
//	cin.tie(0),cout.tie(0);
	cin>>n>>k;
	cin>>s;cin>>x>>y;
	s=' '+s,x=' '+x,y=' '+y;pww[0]=1;
	pw[0]=1;for(int i=1;i<=n;i++) pw[i]=(pw[i-1]*2)%mod,pww[i]=(pww[i-1]*2)%mod;
	for(int i=1;i<n;i++) if(s[i]=='L') s[i]=0;else s[i]=1;
	int sum=pww[n-1],op=0,num=0,pd=0;
	for(int i=2;i<=n;i++){
		if(n-i+1<k-num) break;
		if(x[i]!=y[i]) pd=i;
		int xb=0;
		if(op==0) xb=s[i-1];
		else xb=1-s[i-1];
		sum=(sum+pww[n-i]*xb%mod)%mod;
		if(y[i]=='1'&&pd){
			if(xb==y[i]){
				sum=(sum-pww[n-i]*xb%mod+mod)%mod;
				sum=(sum+pww[n-1]*(1-xb)%mod)%mod;
				num++;op=1-op;
			}
			if(pd==i){
				xiao(i+1,sum,op,num);
			}
			else{
//				cout<<"whx";
				dp[i][num][op]=(dp[i][num][op]+sum)%mod;
				cnt[i][num][op]=(cnt[i][num][op]+1)%mod;
			}
			if(xb==y[i]){
				sum=(sum-pww[n-i]*(1-xb)%mod+mod)%mod;
				sum=(sum+pww[n-1]*xb%mod)%mod;
				num--;op=1-op;
			}
		}
		if(xb!=y[i]-'0'){
			sum=(sum-pww[n-i]*xb%mod+mod)%mod;
			sum=(sum+pww[n-1]*(1-xb)%mod)%mod;
			num++;op=1-op;
		}
		if(i==n&&abs(num-k)<=1&&num<=k) ans+=sum;
	}
	
	sum=pww[n-1],num=0,pd=0;op=1;
	for(int i=2;i<=n;i++){
		if(n-i+1<k-num) break;
		if(x[i]!=y[i]) pd=i;
		int xb=0;
		if(op==0) xb=s[i-1];
		else xb=1-s[i-1];
		sum=(sum+pww[n-i]*xb%mod)%mod;
		if(y[i]=='1'&&pd){
			if(xb==y[i]){
				sum=(sum-pww[n-i]*xb%mod+mod)%mod;
				sum=(sum+pww[n-1]*(1-xb)%mod)%mod;
				num++;op=1-op;
			}
			if(pd==i){
				xiao(i+1,sum,op,num);
			}
			else{
//				cout<<"whx";
				dp[i][num][op]=(dp[i][num][op]+sum)%mod;
				cnt[i][num][op]=(cnt[i][num][op]+1)%mod;
			}
			if(xb==y[i]){
				sum=(sum-pww[n-i]*(1-xb)%mod+mod)%mod;
				sum=(sum+pww[n-1]*xb%mod)%mod;
				num--;op=1-op;
			}
		}
		if(xb!=y[i]-'0'){
			sum=(sum-pww[n-i]*xb%mod+mod)%mod;
			sum=(sum+pww[n-1]*(1-xb)%mod)%mod;
			num++;op=1-op;
		}
		if(i==n&&abs(num-k)<=1&&num<=k) ans+=sum;
	}
	
	for(int i=1;i<n;i++){
		for(int j=0;j<=k;j++){
			for(int ks=0;ks<=1;ks++){
				int xb=s[i+1];
				if(ks==1) xb=1-xb;
				dp[i+1][j][ks]=(dp[i+1][j][ks]+dp[i][j][ks]+cnt[i][j][ks]*pw[n-(i+1)]*xb%mod)%mod;
				cnt[i+1][j][ks]=(cnt[i+1][j][ks]+cnt[i][j][ks])%mod;
				if(j!=k){
					xb=1-xb;ks=ks;
					dp[i+1][1+j][1-ks]=(dp[i+1][j+1][1-ks]+dp[i][j][ks]+cnt[i][j][ks]*pw[n-(i+1)]*xb%mod)%mod;
					cnt[i+1][1+j][1-ks]=(cnt[i+1][j+1][1-ks]+cnt[i][j][ks])%mod;
				}
			}
		}
	}
	ans=(ans+dp[n][k][0]+dp[n][k][1])%mod;
	cout<<ans;
	return 0;
}
